package com.eugene.ui.views;

import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ListViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.ui.part.ViewPart;

public class TestView extends ViewPart {
	ListViewer listViewer ;
	private String[] input = new String[]{"aaa", "bbb", "ccc", "ddd", "eee"};
	final Color white = Display.getCurrent().getSystemColor(SWT.COLOR_WHITE);

	@Override
	public void createPartControl(Composite parent) {
		Composite dialogArea = parent;
		Group group = new Group(dialogArea, SWT.SHADOW_ETCHED_OUT);
		group.setText("Show / Hide");

		GridLayout grid = new GridLayout(3, false);
		group.setLayout(grid);

//		Composite vComp = new Composite(group, SWT.BORDER);
//		vComp.setBackground(white);
//		listViewer = new ListViewer(vComp);
		listViewer = new ListViewer(group);
	    
	    listViewer.setContentProvider(new IStructuredContentProvider() {
	      public Object[] getElements(Object inputElement) {
//	        Vector v = (Vector)inputElement;
	        return input;
	      }
	      
	      public void dispose() {
	        System.out.println("Disposing ...");
	      }

	      public void inputChanged(
	        Viewer viewer,
	        Object oldInput,
	        Object newInput) {
	        System.out.println("Input changed: old=" + oldInput + ", new=" + newInput);
	      }
	    });
	    
	    //listViewer.setContentProvider(new ArrayContentProvider());
	    
	    listViewer.setInput(input);

	}

	@Override
	public void setFocus() {
		// TODO Auto-generated method stub

	}

}
